<div id="receipt_wrapper">
	<div id="receipt_header">
		<div id="company_name"><?php echo  $this->Html->image('smllogo.jpg', array('alt' => 'Pretty Little Treasures', 'border' => '0', 'width' => '180'));?></div>
		<div id="company_address">384 Centre Rd, Bentleigh VIC 3204</div>
        <div id="company_phone">Tel: (03) 9557 3388</div>
		<div id="sale_receipt">Sales Receipt</div>
		<div id="sale_time"><?php echo $this->Time->format("m/d/Y H:i",$sale["created"])?></div>
	</div>
	<div id="employee" style="font-weight:bold;">Customer ID: <?php echo $sale["customer_id"]?></div>

		<table id="receipt_items" style="background-color:#FFFFFF">
	<tbody><tr>




	<?php if(!empty($sale["layby_item"] )){?>
	<tr><td style="font-weight:bold;">Layby Sale -- <?php echo $sale["layby_item"][0]["Item"]["layby_id"]?></td></tr>
	<th style="width:49%;text-align:center;">Item</th>
	<th style="width:20%;text-align:center;">Price</th>
	<th style="width:15%;text-align:center;">Initial payment</th>
	<th style="width:16%;text-align:right;">Amount due</th>
	<?php foreach($sale["layby_item"] as $k=>$v){?>
		<tr>
		<td style="text-align:center;"><span class="long_name"><?php echo $v["Item"]["id"]?> -- <?php echo $v["Item"]["name"]?></span><span class="short_name"><?php echo $v["Item"]["id"]?></span></td>
		<td style="text-align:center;"><?php echo $this->Number->currency($v["Item"]["original_price"],"USD")?></td>
		<td style="text-align:center;"><?php echo $this->Number->currency($v["Item"]["layby_amount"],"USD")?></td>
		<td style="text-align:right;"><?php echo $this->Number->currency($v["Item"]["total"],"USD")?></td>
		</tr>
	<?php }}?>
	<tr>
		<td colspan="6" style="width: 100%;border-bottom: 1px dashed #ccc;">&nbsp;</td>
	</tr>
	<tr>
		<td colspan="6">
			<h3>Previous Layby Payment(s)</h3>
			<table style="width: 60%">
				<tr>
					<th>Payment</th>
					<th>Payment NO.</th>
					<th>Date</th>
					<th>Payment type</th>
					<th>Amount</th>
				</tr><?php $layby_pay_amount=0;?>
				<?php if(!empty($laybyPayments)){?>
				<?php foreach($laybyPayments as $k=>$v){?>
				<tr>
					<td><?php echo $k+1?></td>
					<td><?php echo $v["LaybyPayment"]["id"]?></td>
					<td><?php echo $v["LaybyPayment"]["created"]?></td>
					<td><?php echo $v["PaymentType"]["name"]?></td>
					<td><?php echo $v["LaybyPayment"]["amount"];$layby_pay_amount+=$v["LaybyPayment"]["amount"];?></td>
				</tr>
				<?php }}?>
			</table>
		</td>
	</tr>

    <tr>
    <td colspan="2" align="center"></td>
	<td colspan="2"></td>
	<td colspan="2">&nbsp;</td>
    </tr>
	<tr>
	<td colspan="4" style="text-align:right;">Sub Total</td>
	<td colspan="2" style="text-align:right;"><?php echo $this->Number->currency($sale["layby_item_amount_subtotal"],"USD")?></td>
	</tr>
	<tr>
		<td colspan="4" style="text-align:right;">Amount Due</td>
		<td colspan="2" style="text-align:right"><?php echo $this->Number->currency($sale["layby_item_subtotal"],"USD")?></td>
	</tr>
	<tr>
		<td colspan="4" style="text-align:right;">Layby Amount</td>
		<td colspan="2" style="text-align:right"><?php echo $this->Number->currency($layby_pay_amount,"USD")?></td>
	</tr>
    <tr><td colspan="6">&nbsp;</td></tr>
	<tr>
	<td colspan="4" style="text-align:right;">Total</td>
	<td colspan="2" style="text-align:right"><?php echo $this->Number->currency($sale["layby_item_amount_subtotal"]+$layby_pay_amount,"USD")?></td>
	</tr>
    <tr><td colspan="6">&nbsp;</td></tr>
	</tbody></table>


	<div id="sale_return_policy">
		<h4>Pretty Little Treasure Lay-By Terms and Conditions</h4>
		<ul>
	    		<li>A minimum deposit of 20% must be paid at the time the Lay-By is commenced.</li>
	    		<li>Lay-By is offered for a period of two (2) weeks from the date the deposit is paid.  In some instances (for example, where to total value of the Lay-By exceeds $500), a longer Lay-By term may be negotiated and agreed at the time the Lay-By is commenced.  In such instances, payments will be required fortnightly. </li>
	    		<li>Lay-Bys cannot exceed a 6-week period.</li>
	    		<li>Where a number of items are placed on Lay-By together, all items remain the property of Pretty Little Treasures until the total balance of the Lay-By is paid in full.  </li>
	    		<li>Once the Lay-By becomes due for collection, Pretty Little Treasures will contact clients via SMS with a courtesy reminder to collect goods. Should the Lay-By not be collected within 7 days from the due date, a final reminder will be sent via SMS.  Failure to respond to this final SMS within 3 working days will result in the Lay-By being cancelled, and all monies paid being forfeited.</li>
    		</ul>
	</div>


	<div id="signature"></div>
	</div>
    <button class="submit_button btn" id="print_button" onclick="print_receipt()"> Print </button>





<script type="text/javascript">
function print_receipt()
 {
	printdiv("receipt_wrapper");
 }
function printdiv(printpage)
{
var headstr = "<div style='background-color:white;width:85%;margin:0 auto'>";
var footstr = "</div>";
var newstr = document.all.item(printpage).innerHTML;
var oldstr = document.body.innerHTML;
document.body.innerHTML = headstr+newstr+footstr;
window.print();
document.body.innerHTML = oldstr;
return false;
}
</script>